<?php
/**
* @version 1.0.0
* @package RSSearch! 1.0.0
* @copyright (C) 2011 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/
defined('_JEXEC') or die('Restricted access');

jimport('joomla.form.formfield');
class JFormFieldContentcategoriesField extends JFormField
{
	/**
	 * The form field type.
	 *
	 * @var		string
	 * @since	1.6
	 */
	protected $type = 'ContentcategoriesField';

	/**
	 * Method to get the field input markup.
	 *
	 * @return	string	The field input markup.
	 * @since	1.6
	 */
	protected function getInput()
	{
		$result = '<script type="text/javascript">
				window.addEvent(\'domready\',function(){
					if(document.getElementById("categories_btn").checked){
						document.getElementById("listcategories").style.display="block";
						document.getElementById("desc_categories").style.display="none";
					}else {
						document.getElementById("listcategories").style.display="none";
						document.getElementById("desc_categories").style.display="block";
					}
				});
				</script>';
		$result .= '<div id="desc_categories" style="float:left;display:block;margin-top:10px;">'.JText::_('RSF_CONT_XML_CATEGORIES_LIST_DESC').'</div>';
		$result .= '<div id="listcategories" style="display:none;">';
		$cats = JHtml::_('category.options', 'com_content');
		
		$value = (isset($this->value['categories']) ? $this->value['categories'] : array());
		$tmp = new stdClass();
		$tmp->value 	= 0;
		$tmp->text = JText::_('Uncategorised');
		array_unshift($cats, $tmp);
		
		$result .= JHTML::_('select.genericlist', $cats, $this->name.'[categories][]', 'multiple="multiple"', 'value', 'text', $value);
		$result .= '</div>';

		return $result;
	}
}